import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import themeColor from "./config/theme/themeColor";
import { PORT } from "./config/contant";
import proxy from "./config/proxy/proxy";

import * as path from "path";

import vitePluginImp from "vite-plugin-imp";

export default defineConfig({
	plugins: [
		react(),
		vitePluginImp({
			optimize: true,
			libList: [
				{
					libName: "antd",
					libDirectory: "es",
					style: (name) => `antd/es/${name}/style`,
				},
			],
		}),
	],
	css: {
		preprocessorOptions: {
			less: {
				javascriptEnabled: true, // 支持内联 JavaScript,
				// 自定义样式
				modifyVars: themeColor,
			},
		},
	},
	resolve: {
		alias: [
			{ find: /^~/, replacement: path.resolve(__dirname, "./") },
			{ find: "@", replacement: path.resolve(__dirname, "src") },
			{ find: "@c", replacement: path.resolve(__dirname, "config") },
		],
	},
	server: {
		host: true,
		port: PORT, // 开发环境启动的端口
		proxy,
	},
});
